function setPerson(person, name, value) {
  name in person ? Object.defineProperty(person, name, {
    value: value,
    enumerable: true,
    configurable: true,
    writable: true,
  }) : person[name] = value
  return person;
}

let person;

Component({
  properties: (person = {
    isShowBadge: String,
    userInfo: Object,
    receivedTimeArr: Array,
    paramAtoB: String
  }, setPerson(person, "isShowBadge", String), setPerson(person, "isShowBadge2", String), person),
    data: {
        tabs: [ {
            title: "微信",
            icon: "icon-wechat2"
        }, {
            title: "通讯录",
            icon: "icon-contact"
        }, {
            title: "发现",
            icon: "icon-faxian"
        }, {
            title: "我",
            icon: "icon-wo"
        } ],
        activeIndex: 0,
        sliderOffset: 0,
        sliderLeft: 0
    },
    onLoad: function() {
        let than = this;
        wx.getSystemInfo({
            success: function(res) {
              console.log(res);
              than.setData({
                sliderLeft: (res.windowWidth / than.data.tabs.length - 96) / 2,
                sliderOffset: res.windowWidth / than.data.tabs.length * than.data.activeIndex
              });
            }
        });
    },
    methods: {
        tabClick: function(e) {
            this.triggerEvent("myevent", {
                paramBtoA: e.currentTarget.id
            });
             this.setData({
                sliderOffset: e.currentTarget.offsetLeft,
                activeIndex: e.currentTarget.id
            });

          let title = this.data.tabs[parseInt(e.currentTarget.id)].title;
          wx.setNavigationBarTitle({ title });
        },
        hideBadgeEvent: function(t) {
            this.triggerEvent("hideBadgeEvent", {
                isShowBadge: "none"
            });
        },
        hideBadgeEvent2: function(t) {
            this.triggerEvent("hideBadgeEvent2", {
                isShowBadge2: "none"
            });
        }
    }
});
